package demo1;
import org.quartz.*;

import static org.quartz.JobBuilder.*;
import static org.quartz.SimpleScheduleBuilder.*;
import static org.quartz.TriggerBuilder.*;

public class test {
    public static void main(String[] args) {
        try {
            SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
            Scheduler sched = schedFact.getScheduler();
            //定义job并将其绑定到HelloJob类
//            JobDetail job = newJob(HelloJob.class)
//                    .withIdentity("myJob", "group1")
//                    .build();

            JobDetail job = newJob(DemoJob.class)
                    .withIdentity("myJob", "group1")
                    .usingJobData("jobSays", "Hello World!")
                    .usingJobData("myFloatValue", "3.1415f")
                    .build();

           Trigger trigger = newTrigger()
                    .withIdentity("myTrigger", "group1")
                    .startNow()
                    .withSchedule(simpleSchedule().withIntervalInSeconds(5).repeatForever())
                    .build();

            sched.scheduleJob(job,trigger);
            sched.start();//启动
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
